package text

import (
	

	
	
	
)

// Option represents an option that can be used to configure a text panel.
type Option func(text *Text) error

// Text represents a text panel.
type Text struct {
	Builder *sdk.Panel
}

// New creates a new text panel.
func ( string,  ...Option) (*Text, error) {
	 := &Text{Builder: sdk.NewText()}

	.Builder.IsNew = false
	.Builder.Span = 6

	for ,  := range  {
		if  := ();  != nil {
			return nil, 
		}
	}

	return , nil
}

// Links adds links to be displayed on this panel.
func ( ...links.Link) Option {
	return func( *Text) error {
		.Builder.Links = make([]sdk.Link, 0, len())

		for ,  := range  {
			.Builder.Links = append(.Builder.Links, .Builder)
		}

		return nil
	}
}

// HTML sets the content of the panel, to be rendered as HTML.
func ( string) Option {
	return func( *Text) error {
		.Builder.TextPanel.Mode = "html"
		.Builder.TextPanel.Content = 

		return nil
	}
}

// Markdown sets the content of the panel, to be rendered as markdown.
func ( string) Option {
	return func( *Text) error {
		.Builder.TextPanel.Mode = "markdown"
		.Builder.TextPanel.Content = 

		return nil
	}
}

// Span sets the width of the panel, in grid units. Should be a positive
// number between 1 and 12. Example: 6.
func ( float32) Option {
	return func( *Text) error {
		if  < 1 ||  > 12 {
			return fmt.Errorf("span must be between 1 and 12: %w", errors.ErrInvalidArgument)
		}

		.Builder.Span = 

		return nil
	}
}

// Height sets the height of the panel, in pixels. Example: "400px".
func ( string) Option {
	return func( *Text) error {
		.Builder.Height = &

		return nil
	}
}

// Description annotates the current visualization with a human-readable description.
func ( string) Option {
	return func( *Text) error {
		.Builder.Description = &

		return nil
	}
}

// Transparent makes the background transparent.
func () Option {
	return func( *Text) error {
		.Builder.Transparent = true

		return nil
	}
}